package com.king.config;

import com.jagregory.shiro.freemarker.ShiroTags;
import com.king.template.HotsTemplate;
import com.king.template.PostTemplate;
import com.king.template.TimeAgoMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class FreeMarkerConfig {

    @Autowired
    private freemarker.template.Configuration configuration;

    @Autowired
    private PostTemplate postTemplate;

    @Autowired
    private HotsTemplate hotsTemplate;

    @PostConstruct
    public void setUp(){
        configuration.setSharedVariable("timeAgo",new TimeAgoMethod());
        configuration.setSharedVariable("post",postTemplate);
        configuration.setSharedVariable("hots",hotsTemplate);
        configuration.setSharedVariable("shiro",new ShiroTags());
    }
}
